import { _decorator, Component, Node } from 'cc';
import { BasePanel } from './BasePanel';
import { _platform, _player } from '../Main';
import { TT } from '../platforms/minis/TT';
const { ccclass, property } = _decorator;

@ccclass('SidebarPanel')
export class SidebarPanel extends BasePanel {

    panelName: string = '侧边奖励'
    
    @property(Node)
    navigateNode: Node = null!

    @property(Node)
    gotNode: Node = null!

    start(): void {
        this.refreshButtons()
        super.start()
    }

    refreshButtons() {
        let got: boolean = _player.bonuses.sidebar <= 0
        this.navigateNode.active = !got
        this.gotNode.active = got
    }

    navigate() {
        let tt = _platform.platform
        if (tt instanceof TT) {
            this.close(() => {
                tt.navigateToScene()
            })
        } else {
            this.close()
        }
    }

    got() {
        this.close()
    }
}


